package com.moyun.zbmy.zizhou.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.moyun.zbmy.zizhou.R;
import com.moyun.zbmy.zizhou.beans.SubscriptionNoBean;
import com.moyun.zbmy.zizhou.ui.adapter.holder.BaseAbsHolder;
import com.moyun.zbmy.zizhou.ui.adapter.holder.SubscriptionNoListHolder;
import com.moyun.zbmy.zizhou.ui.util.IListShowData;
import com.ruihang.generalibrary.ui.adapter.BaseHolderAbsAdapter;

import java.util.List;

/**
 * 订阅号GridView 适配器
 */
public class SubscriptionNoAdapter extends BaseHolderAbsAdapter<SubscriptionNoBean, BaseAbsHolder<SubscriptionNoBean>> {


    private Context context;
    private OnSubscriptionNoClickListener accountClickListener;

    public SubscriptionNoAdapter(Context context, List<SubscriptionNoBean> list, OnSubscriptionNoClickListener listener) {
        super(context, list);
        this.context = context;
        this.accountClickListener = listener;
    }


    @Override
    public BaseAbsHolder<SubscriptionNoBean> onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = null;
        BaseAbsHolder holder = null;
        view = LayoutInflater.from(context).inflate(R.layout.item_subscription_no_list, parent, false);
        holder = new SubscriptionNoListHolder(context, view, accountClickListener);

        return holder;
    }


    public void addData(List<SubscriptionNoBean> list) {
        int pos = getItemCount();
        if (null != list) {
            data.addAll(list);
        }
        if (pos > 0) {
            notifyItemRangeChanged(pos, getItemCount());
        }
    }


    @Override
    public int getItemViewType(int position) {
        return 0;//dataList.get(position).getDataViewType();
    }

    @Override
    public void onBindViewHolder(BaseAbsHolder<SubscriptionNoBean> holder, int position) {
        super.onBindViewHolder(holder, position);
    }

//
//    @Override
//    public int getItemCount() {
//        return data.size();
//    }

    public interface OnSubscriptionNoClickListener {
        void OnSubscriptionNoClick(SubscriptionNoBean bean);
    }

}
